<%@ page pageEncoding="utf-8" language="java" %>
<%@ include file="/WEB-INF/views/common/taglib.jsp"%>
<!DOCTYPE html>
<html>
<head>
	<%@ include file="/WEB-INF/views/common/head.jsp"%>
	<title>后台管理系统 - stoat</title>
	
	<style type="text/css">
		.dataTables_paginate .disabled{color:#fff!important;background:#424f5d!important;}
	</style>
	
</head>
<body>
	<sys:msg msgObj="${msg}"/>
	<nav class="breadcrumb">
		<i class="Hui-iconfont">&#xe67f;</i> 首页 
		<span class="c-gray en">&gt;</span> 用户管理 <span class="c-gray en">&gt;</span> 用户列表 
		<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont btn-refresh">&#xe68f;</i></a></nav>
		<div class="page-container">
			<form action="${ctx}/sys/user/list" id="searchForm" method="post">
				<input id="pageNum" name="pageNum" type="hidden" value="${pageInfo.pageNum}"/>
				<input id="pageSize" name="pageSize" type="hidden" value="${pageInfo.pageSize}"/>
				<div class="text-c"> 
					用户名：<input name="userName" value="${prpmUser.userName }" type="text" class="input-text" style="width:120px;"/>
					 日期范围：
					<input type="text" onfocus="WdatePicker({maxDate:'#F{$dp.$D(\'logmax\')||\'%y-%M-%d\'}'})" id="logmin" class="input-text Wdate" style="width:120px;">
					-
					<input type="text" onfocus="WdatePicker({minDate:'#F{$dp.$D(\'logmin\')}',maxDate:'%y-%M-%d'})" id="logmax" class="input-text Wdate" style="width:120px;">
					<button onclick="return page(1,10);" class="btn btn-success" type="submit"><i class="Hui-iconfont">&#xe665;</i> 搜索</button>
				</div>
			</form>
			<div class="cl pd-5 bg-1 bk-gray mt-20"> 
				<span class="l">
					<a href="javascript:;" onclick="datadel()" class="btn btn-danger radius">
					<i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a> 
					<a class="btn btn-primary radius" onclick="user_add('添加用户', '${ctx}/sys/user/toAdd')" href="javascript:;">
					<i class="Hui-iconfont">&#xe600;</i> 添加用户</a>
				</span> 
		 	</div>
			<div class="mt-20">
				<table class="table table-border table-bordered table-bg table-hover table-sort">
					<thead>
						<tr class="text-c">
							<th width="25"><input type="checkbox" name="" value=""></th>
							<th width="80">序号</th>
							<th>用户名</th>
							<th width="80">用户代码</th>
							<th width="80">登录名</th>
							<th width="75">创建人</th>
							<th width="120">创建时间</th>
							<th width="75">更新人</th>
							<th width="120">更新时间</th>
							<th width="120">操作</th>
						</tr>
					</thead>
					<tbody id="tlist">
						<c:forEach items="${pageInfo.list}" var="item" varStatus="index">
							<tr class="text-c">
								<td><input type="checkbox" value="${item.id}" name="itemId"></td>
								<td>${index.index+1 }</td>
								<td>${item.userName}</td>
								<td>${item.userCode}</td>
								<td>${item.loginName}</td>
								<td>${item.createBy}</td>
								<td><fmt:formatDate value="${item.createTime}" pattern="yyyy-MM-dd HH:mm:ss" /></td>
								<td>${item.modifyBy}</td>
								<td><fmt:formatDate value="${item.modifyTime}" pattern="yyyy-MM-dd HH:mm:ss" /></td>
								<td class="f-14 td-manage">
									<a style="text-decoration:none" class="ml-5" onclick="user_edit('修改用户', '${ctx}/sys/user/toAdd?id=${item.id}')" href="javascript:;" title="编辑"><i class="Hui-iconfont">&#xe6df;</i></a> 
									<a style="text-decoration:none" class="ml-5" onclick="user_del('${item.id}')" href="javascript:;" title="删除"><i class="Hui-iconfont">&#xe6e2;</i></a>
								</td>
							</tr>
						</c:forEach>
					</tbody>
				</table>
				
				
				<div class="dataTables_wrapper">
					${fnz:pageStr(pageInfo)}
				</div>
			</div>
		</div>
	
	
	<%@ include file="/WEB-INF/views/common/footer.jsp"%>
	
	<script src="${ctxStatic}/lib/layer/3.0.1/layer.js" type="text/javascript"></script>
	<script src="${ctxStatic}/lib/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
	<script type="text/javascript">

		function page(n,s){
			if(n) $("#pageNum").val(n);
			if(s) $("#pageSize").val(s);
			$("#searchForm").submit();
	    	return false;
	    }
		
		/* 用户-添加 */
		function user_add(title,url){
			var index = layer.open({
				type: 2,
				title: title,
				content: url
			});
			layer.full(index);
		}
		
		//修改
		function user_edit(title, url){
			var index = layer.open({
				type: 2,
				title: title,
				content: url
			});
			layer.full(index);
		}
		
		//删除
		function user_del(id){
			layer.confirm('您确定需要删除这条信息吗？', {
			  btn: ['确定','取消'] //按钮
			}, function(){
			  location.href = ctx + "/sys/user/del/"+id;
			});
		}
		
		//批量删除
		function datadel(){
			var _list = [];
			var index = 0;	
			$("#tlist input[name='itemId']").each(function(){
				if($(this)[0].checked==true){
					console.log($(this)[0].value);
					_list[index++] = $(this)[0].value;
				}
			});
			if(_list.length == 0 ){
				layer.msg('请选择需要删除的信息');
				return;
			} else {
				layer.confirm('您确定需要删除吗？', {
					  btn: ['确定','取消'] //按钮
					}, function(){
					  //location.href = ctx + "/sys/user/datadel?ids="+_list;
					  var url = ctx + "/sys/user/datadel?random="+Math.random();
						$.ajax({
					    	type: "post",
					        url: url,
					        data:{ids:_list},
					        async: false,
					        traditional: true,
					        success: function(data){
					        	if(data=='1'){
					        		layer.msg('删除成功');
					        		location.href = ctx + "/sys/user/list";
					        	} else {
					        		layer.msg('删除失败');
					        	}
							}
						});
					});
			}
		}
	</script>
</body>
</html>